#include "main/utils.h"
using namespace std;

class Solution {
public:
    int minOperationsMaxProfit(vector<int>& customers, int boardingCost, int runningCost) {
      int waiting_num = 0;
      int cur_profit = 0;
      int max_profit = INT_MIN;
      int total_playing_num = 0;
      int count = 0;
      int max_count = 0;
      for (int i = 0; i < customers.size() || waiting_num > 0; ++i) {
        if (i < customers.size())
          waiting_num += customers[i];
        int playing_num = 0;
        if (waiting_num > 4) {
          playing_num = 4;
          waiting_num -= 4;
        } else {
          playing_num = waiting_num;
          waiting_num = 0;
        }
        total_playing_num += playing_num;
        cur_profit = total_playing_num * boardingCost - (i + 1) * runningCost;
        ++count;
        if (cur_profit > max_profit) {
          max_profit = cur_profit;
          max_count = count;
        }
      }
      return max_profit > 0 ? max_count : -1;
    }
};

int main() {
  vector<int> customers = {8, 3};
  int boarding_cost = 5;
  int running_cost = 6;
  Solution su;
  cout << su.minOperationsMaxProfit(customers, boarding_cost, running_cost) << endl;

  return 0;
}
